package org.scorpio.common.base;

import org.scorpio.common.constant.ResultEnum;

import com.alibaba.fastjson.JSON;

/**
 * <p>
 * Title:HttpResult
 * </p>
 * <p>
 * Description: HTTP请求响应数据
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author Li Enbo
 * @date 2017年11月7日下午5:22:16
 */
public class HttpResult<T> {
	/** 编码 */
	private Integer code;
	/** 描述 */
	private String msg;
	/** 数据 */
	private T data;

	/**
	 * 枚举构造
	 */
	public HttpResult(Integer code, String msg, T data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	/**
	 * 枚举构造
	 */
	public HttpResult(ResultEnum resultEnum, T data) {
		super();
		this.code = resultEnum.getCode();
		this.msg = resultEnum.getMsg();
		this.data = data;
	}

	public Integer getCode() {
		return code;
	}

	public HttpResult<T> setCode(Integer code) {
		this.code = code;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public HttpResult<T> setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public T getData() {
		return data;
	}

	public HttpResult<T> setData(T data) {
		this.data = data;
		return this;
	}

	/**
	 * 转json
	 * 
	 * @return
	 */
	public JSON toJson() {
		return this.toJson();
	}
}
